package com.taiyi.renaissancemall.ui.webview;


import com.taiyi.renaissancemall.base.BasePresent;
import com.taiyi.renaissancemall.bean.AgreementsBean;
import com.taiyi.renaissancemall.bean.BaseResultBean;
import com.taiyi.renaissancemall.net.BaseUrl;
import com.taiyi.renaissancemall.net.HttpUtils;
import com.taiyi.renaissancemall.net.callbck.JsonCallback;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Response;

public class WebViewPresent extends BasePresent<WebViewView> {

    public void getAgreement() {
        Map<String, String> map = new HashMap<>();
        HttpUtils.postRequest(BaseUrl.FIND_SYS, this, map, new JsonCallback<BaseResultBean<AgreementsBean>>() {
            @Override
            public BaseResultBean<AgreementsBean> convertResponse(Response response) throws Throwable {
                return super.convertResponse(response);
            }

            @Override
            public void onSuccess(com.lzy.okgo.model.Response<BaseResultBean<AgreementsBean>> response) {
                super.onSuccess(response);
                if (response.body().code == 0) {
                    view.getAgreementSuccess(response.body().data);
                } else {
                    view.onFailure(response.body().msg_cn);
                }
            }

            @Override
            public void onError(com.lzy.okgo.model.Response<BaseResultBean<AgreementsBean>> response) {
                super.onError(response);
            }
        });
    }

}
